import request from '@/api/axios'
import {AxiosPromise} from 'axios'
import {DataRes, Paging} from '@/api/config'

// 实验室名称 labId
// 印章类型	sealTypeName  sealType
// 印章图片 picture
// 印章备注 remark
// 印章状态 status

//电子签章分页查询数据定义
export interface GetSignList extends Paging{
  name?:string|number|null,
  categoryName?:string|null,
  categoryId?:string|number
}

// 搜索数据定义
export interface SearchSignFromData{
  labId:string|number|null,
  sealTypeName:string|null,
  sealType:string|null
}


//表头按钮定义
export type TableOperation='add'

// 电子签章基本信息
export interface BaseSignInfor{
  sealType?:string,
  id?:string|number|null,
  categoryId?:string,
  categoryName?:string,
  cover?:string,
  description?:string,
name?:string,
price?:string,
author?:string
}

//电子签章信息
export interface SignInfor extends BaseSignInfor{
  colorType?:string,
  id:number
}

export type SignFormInfor = Partial<SignInfor>

//获取电子签章管理列表事件
export const getSignList = (params:GetSignList):AxiosPromise<DataRes<any>> => {
  return request({
    url:'/api/book/list',
    method:'get',
    params
  })
}

//电子签章详细信息
export interface SignDetailInfor{
  sealType?:string,
  id?:string|number|null,
  categoryId?:string,
  categoryName?:string,
  cover?:string,
  description?:string,
name?:string,
price?:string,
author?:string
}

//电子签章保存信息
export type SignSaveInfor=SignDetailInfor&(SignInfor|BaseSignInfor)

//保存电子签章信息事件
export const saveSignInfor = (data:SignDetailInfor):AxiosPromise<DataRes<undefined>> => {
  return request({
    url:'/api/book',
    method:'post',
    data
  })
}
//编辑电子签章信息事件
export const editSignInfor = (data:SignDetailInfor):AxiosPromise<DataRes<undefined>> => {
  return request({
    url:'/api/book',
    method:'put',
    data
  })
}
//删除
//根据ID删除字典信息项
export const delDict = (id: any): AxiosPromise<DataRes<null>> => {
  return request({
    url:'/api/book/' + id,
    method: 'DELETE'
  })
}


export  interface OrgInfor{
  id?:number,
  orgId?:number,
  structureName?:string
}

//获取实验室名称
export const getOrgInfor = ():AxiosPromise<DataRes<Array<OrgInfor>>> => {
  return request({
    url:'/api/platform-system/user/deploy/structures',
    method:'get'
  })
}
//字典分页查询
export const getDictionaries = (): AxiosPromise<DataRes<Array<any>>> => {
  return request({
    url: '/api/category/list',
    method: 'get'
  })
}